import Vue from "vue";

import VueRouter from 'vue-router';

Vue.use(VueRouter);//使用路由
const Home = () => import("@/pages/home/Home.vue");//主页面
const Consulting = () => import("@/pages/consulting/Consulting.vue");//咨询页面
const Course = () => import("@/pages/course/Course.vue");//课程
const Base = () => import("@/pages/base/Base.vue");//基地
const Guidelines = () => import("@/pages/guidelines/Guidelines.vue");//路线
const Outcome = () => import("@/pages/outcome/Outcome.vue");//成果展示
const Notice = () => import("@/pages/notice/Notice");//通知公告

const routes = [
    {
        path: "/",
        redirect: "/home"
    },
    {
        path: "/home",
        component: Home,
        meta:{
            title:"首页"
        }
    },
    {
        path: "/consulting",
        component: Consulting,
        meta:{
            title:"咨询"
        }
    },
    {
        path: "/course",
        component: Course,
        meta:{
            title:"课程"
        }
    },
    {
        path: "/base",
        component: Base,
        meta:{
            title:"基地"
        }
    },
    {
        path: "/guidelines",
        component: Guidelines,
        meta:{
            title:"线路"
        }
    },
    {
        path: "/notice",
        component: Notice,
        meta:{
            title:"通知公告"
        }

    },
    {
        path: "/outcome",
        component: Outcome,
        meta:{
            title:"成果展示"
        }
    },
];

const router = new VueRouter({
    routes,
});
//前置守卫
router.beforeEach((to,form,next)=>{
    //设置title
    document.title = to.matched[0].meta.title;
    next();
});

export default router
